<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form-model layout="inline" :model="queryParam" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="6" :sm="10">
            <a-form-model-item label="任务名称" prop="jobClassName">
              <a-input placeholder="请输入任务名称" v-model="queryParam.taskName"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :md="6" :sm="10">
            <a-form-model-item label="任务类型" prop="taskType">
                <j-multi-select-tag type="list_multi" placeholder="请选择任务类型" v-model="queryParam.sourceList"
                                    dictCode="task_type"></j-multi-select-tag>

            </a-form-model-item>
          </a-col>

          <a-col :md="6" :sm="10">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form-model>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
             <a @click="handleEdit(record)">编辑</a>
            <a-divider type="vertical"/>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete1(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
        </span>
      </a-table>
    </div>
    <!-- 表单区域 -->
    <index-task-modal ref="modalForm" @ok="modalFormOk"></index-task-modal>

  </a-card>
</template>

<script>
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import moment from 'moment'
  import JInput from '@/components/jeecg/JInput'
  import IndexTaskModal from './modules/IndexTaskModal'
  export default {
    name: "IndexTask",
    mixins: [JeecgListMixin],
    components: {JInput,moment,IndexTaskModal},
    data() {
      return {
        columns:
          [
            {
              title: '任务名称',
              align: 'center',
              dataIndex: 'taskName'
            },
            {
              title: '任务类型',
              align: 'center',
              dataIndex: 'taskType_dictText',
            },
            {
              title: '创建人',
              align: "center",
              width: 80,
              dataIndex: 'createBy',
            },
            {
              title: '描述',
              align:"center",
              width: 250,
              dataIndex: 'description',
              scopedSlots: {customRender: 'description'},
            },
            {
              title: '创建时间',
              align: "center",
              dataIndex: 'createTime'
            },
            {
              title: '操作',
              dataIndex: 'action',
              align: 'center',
              scopedSlots: {customRender: 'action'}
            }
          ],
        url: {
          list: "/sys/IndexTask/list",
          eleteBatch: "/sys/IndexTask/deleteBatch",
          delete: '/sys/IndexTask/delete',
          deleteBatch: "/sys/IndexTask/deleteBatch",
        },
      }
    },
    methods: {
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = '编辑'
      },
      handleDelete1: function (id) {
        this.handleDelete(id)
      },
      handleMenuClick(e) {
        if (e.key == 1) {
          this.batchDel();
        }
      },

    }

  }
</script>

<style scoped>

</style>